import { createRouter, createWebHashHistory } from 'vue-router'
import Index from "../views/Index.vue"
import Message from "../views/Message.vue";
import GoodsManage from "../views/GoodsManage.vue";
import Evaluate from "../views/Evaluate.vue"
import Order from "../views/Order.vue"
import Fund from "../views/Fund.vue";
import OrderDetails from "../views/OrderDetails.vue";
import UserHomePage from "../views/UserHomePage.vue";
import PlatformRules from "../views/PlatformRules.vue";
import AppDownload from "../views/AppDownload.vue";
import WeChatBinding from "../views/WeChatBinding.vue";
import SetUp from "../views/SetUp.vue";
import CreateCommodity from "../views/CreateCommodity.vue";
import Login from "@/views/login.vue";
import EditUser from "@/views/EditUser.vue";
import RealName from "@/views/RealName.vue";
import Agreement from "@/views/agreement.vue";
import GoodsDetails from "@/views/GoodsDetails.vue";
import CreateUser from "@/views/CreateUser.vue";
import CreateEnd from "@/views/CreateEnd.vue";
import OneMessage from '@/views/OneMessage.vue';

const router = createRouter({
  history: createWebHashHistory(),
  routes: [
    {
      path: '/',
      name: 'Index',
      component: Index,
      meta: {
        title: '首页'
      },
      redirect: "/message",
      children: [
        {
          path: "/message",
          name: "Message",
          component: Message,
          meta: {
            title: "消息"
          }
        },
        {
          path: "/goodsManage",
          name: "GoodsManage",
          component: GoodsManage,
          meta: {
            title: "卖技能"
          }
        },
        {
          path: "/evaluate",
          name: "Evaluate",
          component: Evaluate,
          meta: {
            title: "评价"
          }
        },
        {
          path: "/order",
          name: "Order",
          component: Order,
          meta: {
            title: "订单"
          }
        },
        {
          path: "/orderDetails",
          name: "OrderDetails",
          component: OrderDetails,
          meta: {
            title: "订单详情"
          }
        },
        {
          path: "/fund",
          name: "Fund",
          component: Fund,
          meta: {
            title: "资金"
          }
        },
        {
          path: "/userHomePage",
          name: "UserHomePage",
          component: UserHomePage,
          meta: {
            title: "我的主页"
          }
        },
        {
          path: "/platformRules",
          name: "PlatformRules",
          component: PlatformRules,
          meta: {
            title: "平台规则"
          }
        },
        {
          path: "/appDownload",
          name: "AppDownload",
          component: AppDownload,
          meta: {
            title: "下载APP"
          }
        },
        {
          path: "/weChatBinding",
          name: "WeChatBinding",
          component: WeChatBinding,
          meta: {
            title: "绑定微信消息通知"
          }
        },
        {
          path: "/setUp",
          name: "SetUp",
          component: SetUp,
          meta: {
            title: "设置"
          }
        },
        {
          path: "/createCommodity",
          name: "CreateCommodity",
          component: CreateCommodity,
          meta: {
            title: "新建商品"
          }
        },
        {
          path: "/GoodsDetails",
          name: "GoodsDetails",
          component: GoodsDetails,
          meta: {
            title: "商品详情"
          }
        },
      ]
    },
    {
      path: "/login",
      name: "Login",
      component: Login,
      meta: {
        title: "登录"
      }
    },
    {
      path: "/oneMessage",
      name: "OneMessage",
      component: OneMessage,
      meta: {
        title: "一封信"
      }
    },
    {
      path: "/createUser",
      name: "CreateUser",
      component: CreateUser,
      meta: {
        title: "如何入驻？"
      }
    },
    {
      path: "/editUser",
      name: "EditUser",
      component: EditUser,
      meta: {
        title: "信息填写"
      }
    },
    {
      path: "/createEnd",
      name: "CreateEnd",
      component: CreateEnd,
      meta: {
        title: "入驻成功"
      }
    },
    {
      path: "/realName",
      name: "RealName",
      component: RealName,
      meta: {
        title: "实名认证"
      }
    },
    {
      path: "/agreement",
      name: "Agreement",
      component: Agreement,
      meta: {
        title: "协议/规则"
      }
    }
  ]
})


router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = `技能猴子-${to.meta.title}`
  }
  next()
})

export default router
